/***************************************************
 @Name :        小铭同学
 @Time :        2025-09-03
 @Email :       LiaoMingWJ233@163.com
 @Comment :     温湿度 显示窗口
 @FileName :    temhum.cpp
 @Version :     1.0
****************************************************/


#include "temhum.h"
#include "ui_temhum.h"

TemHum::TemHum(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TemHum)
{
    ui->setupUi(this);
    
    TH_chart *chart = new TH_chart(this);
    
    timer = new QTimer;
    temhum = new TemHumDevice();
    
    connect(timer, &QTimer::timeout, this, [=](){
        chart->setTemperature(temhum->temCollect());     // 设置温度
        chart->setHumidity(temhum->humCollect());        // 设置湿度
    });
    
    timer->start(500);
        
    chart->setRange(-10, 50, 0, 100); // 设置范围
    chart->setAnimationEnabled(true); // 启用动画
    chart->setFixedChartSize(700,400);// 设置大小
}

TemHum::~TemHum()
{
    delete ui;
}
